package com.example.esaclient;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;



public class WsConnection {
	
	private static final String NAMESPACE = "http://tempuri.org/";
	private static final String URL = "http://192.168.0.6:80/ServiceRest.svc";
	
	private static final String SOAP_ACTION = "http://tempuri.org/IServiceRest/";
	public  String METHOD_NAME = "LoginCompany";
	
	
	public String LoginCompany(final String email, final String pwd){
		    final String resultData = new String();
	Thread networkThread = new Thread() {
	    @Override
	    public void run() {
	      try {
	         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);         
	         request.addProperty("email", email);
	         request.addProperty("password", pwd); 
	         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	         envelope.dotNet= true;		         
	         envelope.setOutputSoapObject(request);
	          
	         HttpTransportSE ht = new HttpTransportSE(URL);
	         ht.debug=true;
	         ht.call(SOAP_ACTION+METHOD_NAME, envelope);
	       //  ht.call(NAMESPACE + METHOD_NAME, envelope);
	         
	        
	         Object result = envelope.getResponse();
	          
	           SoapPrimitive s = (SoapPrimitive)result;
	        // final  SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	           resultData.concat(s.toString());
	 
	        
	      }
	     catch (Exception e) {
	         e.printStackTrace();
	     }
	    }
	  };
	  networkThread.start();
	  
	  return resultData;
	}
	      
	    }
	    
